package com.grandtech.insurance.common.db.jdbc.pg;


public final class Constant {

    public final static String FEATURE_UPDATE_TIME = "updatetime";

    /**
     * 要素状态
     */
    public enum FeatureStatus {
        //删除
        DEL {
            @Override
            public int getValue() {
                return -1;
            }

            @Override
            public String toString() {
                return "DEL";
            }

            @Override
            public String getDesc() {
                return "删除";
            }
        },
        //正常
        UNDO {
            @Override
            public int getValue() {
                return 0;
            }

            @Override
            public String toString() {
                return "UNDO";
            }

            @Override
            public String getDesc() {
                return "正常";
            }
        },
        //修改
        MODIFY {
            @Override
            public int getValue() {
                return 1;
            }

            @Override
            public String toString() {
                return "MODIFY";
            }

            @Override
            public String getDesc() {
                return "修改";
            }
        },
        //新增
        ADD {
            @Override
            public int getValue() {
                return 2;
            }

            @Override
            public String toString() {
                return "ADD";
            }

            @Override
            public String getDesc() {
                return "新增";
            }
        };

        public final static String FEATURE_STATUS = "status";

        /**
         * @return 对应整数值
         */
        public abstract int getValue();

        public abstract String toString();

        public abstract String getDesc();

        /**
         * 根据枚举整型表达式获取枚举对象
         */
        public static FeatureStatus getEnumByCode(int code) {
            FeatureStatus state = null;

            for (int i = 0; i < FeatureStatus.values().length; i++) {
                if (FeatureStatus.values()[i].getValue() == code) {
                    state = FeatureStatus.values()[i];
                    break;
                }
            }
            return state;
        }

        /**
         * 根据枚举描名称获取枚举对象
         */
        public static FeatureStatus getEnumByName(String name) {
            FeatureStatus state = null;
            for (int i = 0; i < FeatureStatus.values().length; i++) {
                if (FeatureStatus.values()[i].toString().equalsIgnoreCase(name.trim())) {
                    state = FeatureStatus.values()[i];
                    break;
                }
            }
            return state;
        }

        /**
         * 根据枚举描述信息表达式获取枚举对象
         */
        public static FeatureStatus getEnumByDesc(String desc) {
            FeatureStatus state = null;
            for (int i = 0; i < FeatureStatus.values().length; i++) {
                if (FeatureStatus.values()[i].getDesc().equalsIgnoreCase(desc.trim())) {
                    state = FeatureStatus.values()[i];
                    break;
                }
            }
            return state;
        }
    }

    /**
     * 切片状态
     */
    public enum TileStatus {
        //未切片
        UN {
            @Override
            public int getValue() {
                return 0;
            }

            @Override
            public String toString() {
                return "tilestatus";
            }

            @Override
            public String getDesc() {
                return "未切片";
            }
        },
        //已切片
        ED {
            @Override
            public int getValue() {
                return 1;
            }

            @Override
            public String toString() {
                return "tilestatus";
            }

            @Override
            public String getDesc() {
                return "已切片";
            }
        };

        public final static String TILE_STATUS = "tilestatus";

        /**
         * @return 对应整数值
         */
        public abstract int getValue();

        public abstract String toString();

        public abstract String getDesc();

        /**
         * 根据枚举整型表达式获取枚举对象
         */
        public static TileStatus getEnumByCode(int code) {
            TileStatus state = null;

            for (int i = 0; i < TileStatus.values().length; i++) {
                if (TileStatus.values()[i].getValue() == code) {
                    state = TileStatus.values()[i];
                    break;
                }
            }
            return state;
        }

        /**
         * 根据枚举描名称获取枚举对象
         */
        public static TileStatus getEnumByName(String name) {
            TileStatus state = null;
            for (int i = 0; i < TileStatus.values().length; i++) {
                if (TileStatus.values()[i].toString().equalsIgnoreCase(name.trim())) {
                    state = TileStatus.values()[i];
                    break;
                }
            }
            return state;
        }

        /**
         * 根据枚举描述信息表达式获取枚举对象
         */
        public static TileStatus getEnumByDesc(String desc) {
            TileStatus state = null;
            for (int i = 0; i < TileStatus.values().length; i++) {
                if (TileStatus.values()[i].getDesc().equalsIgnoreCase(desc.trim())) {
                    state = TileStatus.values()[i];
                    break;
                }
            }
            return state;
        }
    }


}
